package com.guoxue.action.back;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.guoxue.action.front.BaseAction;
import com.guoxue.service.IUserService;
import com.guoxue.util.LoggerUtil;
@Controller
@RequestMapping("User")
public class BackAccountAction extends BaseAction{
	@Resource
	private IUserService userService;
	/**
	 * 后台管理禁用和启用用户
	 *  @param 用户id
	 * 
	 * */
	@RequestMapping("/del/member")
	@ResponseBody
	public JSON changeUserStatus(HttpServletRequest req, HttpServletResponse resp, Integer id) {
		try {
			userService.updateAccountStatus(id, 3);
			return Message(SUCCESS, "封号成功", null);
		} catch (Exception e) {
			return LoggerUtil.logInfo(e, "封号失败");
		}
	}
	/**
	 * 解锁账号
	 * 
	 * @param req
	 * @param resp
	 * @param id
	 * @return
	 */
	@RequestMapping("unblock/member")
	@ResponseBody
	public JSON unblocking(HttpServletRequest req, HttpServletResponse resp, Integer id) {
		try {
			userService.updateAccountStatus(id, 1);
			return Message(SUCCESS, "解除封号成功", null);
		} catch (Exception e) {
			return LoggerUtil.logInfo(e, "解除封号失败");
		}
	}
}
